package OnlineExam.question;

import javax.servlet.*;
import javax.servlet.http.*;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
import org.apache.struts.action.*;
import OnlineExam.*;
import OnlineExam.question.*;
import OnlineExam.db.*;


/**
 *  Deletes a Question from the questionBank.
 */


public class DeleteQuestionAction extends Action
{
	
	/** 
	 *  Deletes a given Question from the QuestionBank.
	 */

		
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, 
					HttpServletResponse response)
	{
		
		try 
		{
			int rowCount = DBUtil.delete("QuestionBank", "Number", Integer.parseInt(request.getParameter("questionNumber")));

			return (mapping.findForward("success"));
		}
		catch (DBException e)
		{
			System.out.println("Exception.." + e);
			return (mapping.findForward("dbError"));
		}
	}
}
